package com.dao;

import com.entity.Employee;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author cj
 * @date 2019/10/14
 */
public interface EmployeeDao {


    @Select("select id,username,deptid from employee where id= #{id}")
    @Results({
            @Result(column = "id", property = "id", id = true),
            @Result(column = "username", property = "username"),
            @Result(column = "deptid",property = "dept",
            one = @One(select = "com.dao.DeptDao.getDeptById")
            )
    })
    Employee getEmpById(int id);


    @Select("select id,username from employee where deptid=#{deptid}")
    List<Employee> getEmpsByDeptId(int deptid);
}
